package com.my.cd.proxy;

import java.rmi.RemoteException;
import java.util.ArrayList;

/**
 * 糖果机监控类
 */
public class Monitor {

    private ArrayList<CandyMachineRemote> candyMachinelst;

    public Monitor() {
        candyMachinelst = new ArrayList<>();
    }

    public void addMachine(CandyMachineRemote mCandyMachine) {
        candyMachinelst.add(mCandyMachine);
    }

    public void report() {
        for (CandyMachineRemote mCandyMachine : candyMachinelst) {
            try {
                System.out.println("Machine Loc:" + mCandyMachine.getLocation());
                System.out.println("Machine Candy count:" + mCandyMachine.getCount());
                System.out.println("Machine State:" + mCandyMachine.getState().getStateName());
            } catch (RemoteException e) {
                e.printStackTrace();
            }
        }
    }
}
